document.querySelector("button#synth").addEventListener("click", () => {
  const text = document.querySelector("textarea#text").value;
  const speaker = document.querySelector("select#speaker").value;
  tts
    .synth(text, speaker)
    .catch(alert)
    .then((val) => {
      if (val.code === 3000) {
        document.querySelector(
          "audio"
        ).src = `data:audio/mpeg;base64,${val.data}`;
      } else {
        alert(`error ${val.code}`);
      }
    });
});
